/*
* pps_bom
*/
package com.pitop.assembly.service;

import com.pitop.assembly.api.AssemblyLogFeignApi;
import com.pitop.assembly.entity.AssemblyLog;
import com.pitop.core.entity.Page;
import com.pitop.core.exceptions.AssemblyLogException;
import com.pitop.core.exceptions.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 组件日志
 *
 * @author berton
 */
@Service("assemblyLogSVImpl")
@Slf4j
public class AssemblyLogSVImpl {

    @Autowired
    private AssemblyLogFeignApi assemblyLogFeignApi;

    /**
     * 加载一个对象AssemblyLog
     *
     * @param id
     * @return AssemblyLog
     */
    public AssemblyLog load(Long id) {
        if (id == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return assemblyLogFeignApi.load(id);
    }

    /**
     * 加载一个对象AssemblyLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return AssemblyLog
     */
    public AssemblyLog loadById(Long id) {
        if (id == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return assemblyLogFeignApi.loadById(id);
    }

    /**
     * 加载一个对象AssemblyLog,(将查询关联数据)
     *
     * @param id
     * @return AssemblyLog
     */
    public AssemblyLog get(Long id) {
        if (id == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return assemblyLogFeignApi.get(id);
    }

    /**
     * 加载一个对象AssemblyLog 通过id,(将查询关联数据)
     *
     * @param id
     * @return AssemblyLog
     */
    public AssemblyLog getById(Long id) {
        if (id == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        return assemblyLogFeignApi.getById(id);
    }

    /**
     * 删除对象AssemblyLog
     *
     * @param id
     */

    public void delete(Long id) {
        if (id == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        assemblyLogFeignApi.delete(id);
    }

    /**
     * 查询AssemblyLog分页
     *
     * @param assemblyLog 对象
     * @param curPage     当前页
     * @param pageSize    分页条数
     * @return List<AssemblyLog>
     */
    public List<AssemblyLog> list(AssemblyLog assemblyLog, int curPage, int pageSize) {
        return assemblyLogFeignApi.list(assemblyLog, curPage, pageSize);
    }

    /**
     * 查询AssemblyLog分页
     *
     * @param id
     * @param curPage  当前页
     * @param pageSize 分页条数
     * @return List<AssemblyLog>
     */
    public List<AssemblyLog> list(Long id, int curPage, int pageSize) {
        if (curPage < 0) {
            curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        AssemblyLog assemblyLog = new AssemblyLog();
        assemblyLog.setId(id);

        return assemblyLogFeignApi.list(assemblyLog, curPage, pageSize);
    }

    public int count(Long id) {
        return assemblyLogFeignApi.count(id);
    }

    public int count(AssemblyLog assemblyLog) {
        return assemblyLogFeignApi.count(assemblyLog);
    }

    /**
     * 保存
     *
     * @param assemblyLog 实体
     * @throws BaseException
     */
    public void save(AssemblyLog assemblyLog) {
        if (assemblyLog == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        assemblyLogFeignApi.build(assemblyLog);
    }

    /**
     * 更新
     *
     * @param assemblyLog 实体
     * @throws BaseException
     */
    public void modify(AssemblyLog assemblyLog) {
        if (assemblyLog == null) {
            throw new AssemblyLogException(BaseException.BaseExceptionEnum.Illegal_Param);
        }
        assemblyLogFeignApi.modify(assemblyLog);
    }
}
